<?php
  $v1 = [1,4,3,6,7];
  $sum = 0;
  $len = count($v1);
  for($i = 0;$i<$len;$i++){
      $sum+=$v1[$i];
  }
  echo "$sum";
  echo "<hr>";

  $v2 = [
      [1,2,3,4],
      [5,6,7,8],
      [9,10]
  ];

  $length = count($v2);
  $sum1 = 0;
  $ave = 0;
  for($k=0;$k<$length;$k++){
       $arr = $v2[$k];
       $length1 = count($arr);
       $ave += $length1;
       for($j=0;$j<$length1;$j++){
           $sum1 += $arr[$j];
       }
  }
  echo "$sum1";
  $average = $sum1/$ave;
  echo "<br>$average";
?>